"""
Author: yongfa
Date: 2020-11-19 16:36:07
LastEditTime  2023-09-07 09:49:12
LastEditors   yongfa
Description: 通用变量
"""

from enum import Enum, unique


@unique
class UserEnum(Enum):
    """
    用法: ScopeEnum(1) == ScopeEnum.COMMON # True
    """
    COMMON = 1  # 普通用户
    ADMIN = 2  # 管理员

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.value, cls))


@unique
class LoginTypeEnum(Enum):
    """
    登录类型
    """
    PASSWORD = 1  # 密码登录
    CODE = 2  # 验证码登录

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.value, cls))


@unique
class OperTypeEnum(Enum):
    '''操作日志类型'''
    OTHER = 0  # 其他
    CREATE = 1  # 新增
    UPDATE = 2  # 修改
    DELETE = 3  # 删除
    GRANT = 4  # 授权
    EXPORT = 5  # 导出
    IMPORT = 6  # 导入
    FORCE = 7  # 强退
    GEN_CODE = 8  # 生成代码
    CLEAN = 9  # 清空数据

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.value, cls))


@unique
class MethodEnum(Enum):
    NULL = ''
    GET = 'GET'
    POST = 'POST'
    PUT = 'PUT'
    DELETE = 'DELETE'

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.value, cls))


@unique
class ResumeEmailProtocolEnum(Enum):
    POP3 = 'POP3'
    IMAP = 'IMAP'

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.value, cls))


@unique
class ResumeEmailTaskEnum(Enum):
    INIT = 0  # 初始化
    LOGIN_FAIL = 1  # 登录失败
    LOGIN_SUCCESS = 2  # 登录成功
    SCANING = 3  # 扫描邮件中
    SCANED = 4  # 扫描完成
    PARSERING = 5  # 解析邮件中
    PARSERED = 6  # 解析完成

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.name, cls))


@unique
class ResumeEmailStatusEnum(Enum):
    INIT = 0  # 初始化
    FILE_ERROR = 1  # 提出文件错误
    PRASERING = 2  # 解析中
    PARSERED = 3  # 解析完成
    PARSER_ERROR = 4  # 解析失败


@unique
class ResumeEmailParserStatusEnum(Enum):
    INIT = 0  # 初始化
    FILE_ERROR = 1  # 提出文件文本错误
    FILE_SUCCESS = 2  # 提出文件文本成功
    PRASERING = 3  # 解析中
    PARSED = 4  # 解析完成
    PARSE_ERROR = 5  # 解析失败


@unique
class ResumeEmailParserPlatformEnum(Enum):
    SELF = 0  # 自定义
    JOB51 = 1  # 51job
    ZHILIAN = 2  # 智联
    BOSS = 3  # Boss


@unique
class ResumeEmailParserTypeEnum(Enum):
    TEXT = 0  # 文本
    FILE = 1  # 文件

    @classmethod
    def list_values(cls):
        """列出所有枚举值"""
        return list(map(lambda x: x.value, cls))
